package com.yc.controller;

import com.yc.bean.FoodDetailBean;
import com.yc.model.ResponseResult;
import com.yc.service.DetailBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zwei
 * @create 2024-10-07 16:06
 */
@RestController
@RequestMapping("/fooddetail")
public class FoodDetailController {
    private final DetailBiz detailBiz;
    @Autowired
    public FoodDetailController(DetailBiz detailBiz) {
        this.detailBiz = detailBiz;
    }
    @PostMapping("/getfooddetail/{foodid}")
    public ResponseResult getfooddetail(@PathVariable Integer foodid){
        List<FoodDetailBean>list=detailBiz.getfooddetail(foodid);
        return ResponseResult.ok().setData(list);
    }
    @PostMapping("/occupancy/{id}")
    public ResponseResult occupancy(@PathVariable Integer id){
        Boolean occupancy=detailBiz.occupancy(id);
        if (occupancy){
            return ResponseResult.ok();
        }else {
            return ResponseResult.error();
        }
    }
    @PostMapping("/release/{id}")
    public ResponseResult release(@PathVariable Integer id){
        Boolean release=detailBiz.occupancy(id);
        if (release){
            return ResponseResult.ok();
        }else {
            return ResponseResult.error();
        }
    }

}
